<!--

    Copyright © 2016-2025 The Thingsboard Authors

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<ng-container [formGroup]="countWidgetConfigForm">
  <tb-image-cards-select rowHeight="3:1"
                         [cols]="{columns: 2,
                                    breakpoints: {
                                      'lt-md': 1
                                    }}"
                         label="{{ 'widgets.count.layout' | translate }}" formControlName="layout">
    <tb-image-cards-select-option *ngFor="let layout of countCardLayouts"
                                  [value]="layout"
                                  [image]="countCardLayoutImageMap.get(layout)">
      {{ countCardLayoutTranslationMap.get(layout) | translate }}
    </tb-image-cards-select-option>
  </tb-image-cards-select>
  <div class="tb-form-row">
    <mat-slide-toggle class="mat-slide" formControlName="autoScale">
      {{ 'widgets.count.auto-scale' | translate }}
    </mat-slide-toggle>
  </div>
  <div class="tb-form-row column-xs">
    <mat-slide-toggle class="mat-slide fixed-title-width" formControlName="showLabel">
      {{ 'widgets.count.label' | translate }}
    </mat-slide-toggle>
    <div class="flex flex-1 flex-row items-center justify-start gap-2">
      <mat-form-field class="flex" appearance="outline" subscriptSizing="dynamic">
        <input matInput formControlName="label" placeholder="{{ 'widget-config.set' | translate }}">
      </mat-form-field>
      <tb-font-settings formControlName="labelFont"
                        [previewText]="countWidgetConfigForm.get('label').value">
      </tb-font-settings>
      <tb-color-settings formControlName="labelColor" settingsKey="{{'widgets.count.label' | translate }}">
      </tb-color-settings>
    </div>
  </div>
  <div class="tb-form-row column-xs">
    <mat-slide-toggle class="mat-slide fixed-title-width" formControlName="showIcon">
      {{ 'widgets.count.icon' | translate }}
    </mat-slide-toggle>
    <div class="flex flex-1 flex-row items-center justify-start gap-2">
      <mat-form-field appearance="outline" class="number flex" subscriptSizing="dynamic">
        <input matInput type="number" min="0" formControlName="iconSize" placeholder="{{ 'widget-config.set' | translate }}">
      </mat-form-field>
      <tb-css-unit-select class="flex-1" formControlName="iconSizeUnit"></tb-css-unit-select>
      <tb-material-icon-select asBoxInput
                               iconClearButton
                               [color]="countWidgetConfigForm.get('iconColor').value?.color"
                               [backgroundColor]="countWidgetConfigForm.get('iconBackgroundColor').enabled
                                                          ? countWidgetConfigForm.get('iconBackgroundColor').value?.color
                                                          : ''"
                               formControlName="icon">
      </tb-material-icon-select>
      <tb-color-settings formControlName="iconColor" settingsKey="{{'widgets.count.icon' | translate }}">
      </tb-color-settings>
    </div>
  </div>
  <div class="tb-form-row column-xs">
    <mat-slide-toggle class="mat-slide fixed-title-width" formControlName="showIconBackground">
      {{ 'widgets.count.icon-background' | translate }}
    </mat-slide-toggle>
    <div class="flex flex-1 flex-row items-center justify-start gap-2">
      <mat-form-field appearance="outline" class="number flex" subscriptSizing="dynamic">
        <input matInput type="number" min="0" formControlName="iconBackgroundSize" placeholder="{{ 'widget-config.set' | translate }}">
      </mat-form-field>
      <tb-css-unit-select class="flex-1" formControlName="iconBackgroundSizeUnit"></tb-css-unit-select>
      <tb-color-settings formControlName="iconBackgroundColor" settingsKey="{{'widgets.count.icon-background' | translate }}">
      </tb-color-settings>
    </div>
  </div>
  <div class="tb-form-row space-between">
    <div translate>widgets.count.value</div>
    <div class="flex flex-row items-center justify-start gap-2">
      <tb-font-settings formControlName="valueFont"
                        previewText="10">
      </tb-font-settings>
      <tb-color-settings formControlName="valueColor" settingsKey="{{'widgets.count.value' | translate }}">
      </tb-color-settings>
    </div>
  </div>
  <div class="tb-form-row column-xs">
    <mat-slide-toggle class="mat-slide fixed-title-width" formControlName="showChevron">
      {{ 'widgets.count.chevron' | translate }}
    </mat-slide-toggle>
    <div class="flex flex-1 flex-row items-center justify-start gap-2">
      <mat-form-field appearance="outline" class="number flex" subscriptSizing="dynamic">
        <input matInput type="number" min="0" formControlName="chevronSize" placeholder="{{ 'widget-config.set' | translate }}">
      </mat-form-field>
      <tb-css-unit-select class="flex-1" formControlName="chevronSizeUnit"></tb-css-unit-select>
      <tb-color-input asBoxInput
                      colorClearButton
                      formControlName="chevronColor">
      </tb-color-input>
    </div>
  </div>
</ng-container>
